package com.tanhua.server.controller;

import com.tanhua.domain.db.UserInfo;
import com.tanhua.domain.vo.PageResult;
import com.tanhua.domain.vo.RecommendUserQueryParam;
import com.tanhua.domain.vo.TodayBestVo;
import com.tanhua.server.service.SettingService;
import com.tanhua.server.service.TodayBestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 今日佳人控制层
 */
@RestController
@RequestMapping("/tanhua")
public class TodayBestController {

    @Autowired
    private TodayBestService todayBestService;

    /**
     * 首页-今日佳人
     */
    @RequestMapping(value = "/todayBest", method = RequestMethod.GET)
    public ResponseEntity todayBest() {
        TodayBestVo todayBestVo = todayBestService.todayBest();
        return ResponseEntity.ok(todayBestVo);
    }

    /**
     * 首页-佳人列表数据分页查询
     */
    @RequestMapping(value = "/recommendation", method = RequestMethod.GET)
    public ResponseEntity recommendation(RecommendUserQueryParam recommendUserQueryParam) {
        PageResult<TodayBestVo> pageResult = todayBestService.recommendation(recommendUserQueryParam);
        return ResponseEntity.ok(pageResult);
    }


    /**
     * 查看用户详情
     * {id}：佳人用户id
     */
    @RequestMapping(value = "/{id}/personalInfo", method = RequestMethod.GET)
    public ResponseEntity personalInfo(@PathVariable("id") Long personUserId) {
        TodayBestVo todayBestVo = todayBestService.personalInfo(personUserId);
        return ResponseEntity.ok(todayBestVo);
    }

    /**
     * 查询陌生人问题
     * userId:佳人用户id
     */
    @RequestMapping(value = "/strangerQuestions", method = RequestMethod.GET)
    public ResponseEntity strangerQuestions(Long userId) {
        String txt = todayBestService.strangerQuestions(userId);
        return ResponseEntity.ok(txt);
    }



    /**
     * 回复陌生人问题
     */
    @RequestMapping(value = "/strangerQuestions", method = RequestMethod.POST)
    public ResponseEntity strangerQuestions(@RequestBody Map params) {
        Long userId = Long.parseLong(params.get("userId").toString());
        String reply = (String)params.get("reply");//回复内容
        todayBestService.replyStrangerQuestions(userId,reply);
        return ResponseEntity.ok(null);
    }

    /**
     * 探花-喜欢
     */
    @GetMapping("/{id}/love")
    public ResponseEntity likeVoiceBecomeFriend(@PathVariable("id")Long id) {
        //调用service业务层 传入当前用户id
        todayBestService.likeVoiceBecomeFriend(id);
        //返回状态信息
        return ResponseEntity.ok(null);
    }
    /**
     * 探花-不喜欢
     */
    @GetMapping("/{id}/unlove")
    public ResponseEntity unlikeVoiceBecomeFriend(@PathVariable("id")Long id) {
        //调用service业务层 传入当前用户id
        todayBestService.unlikeVoiceBecomeFriend(id);
        //返回状态信息
        return ResponseEntity.ok(null);
    }
}
